<template>
    <a-button-group>
        <a-button v-for="mb in baseMenuButton" :key="mb.code" @click="callParentFunc(mb.code)" size="small">
            <button-icon :iconName="mb.icon" />
            {{ getName(mb.code) }}
        </a-button>
    </a-button-group>
</template>

<script setup lang='ts'>
import i18n from '@/i18n';
import ButtonIcon from '../icon/index.vue';
import type { MenuButtonResultDto } from '@/models/menu-button';
import { toCamelCase } from '@/utils';

defineProps<{ baseMenuButton: Array<MenuButtonResultDto> }>();
const emit = defineEmits(['callFunc']);

function getName(code: string): string {
    return i18n.global.t("menuButton." + toCamelCase(code));
}

function callParentFunc(funcName: string): void {
    funcName = funcName === 'Delete' ? 'remove' : toCamelCase(funcName)
    emit("callFunc", funcName);
}
</script>